home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / demosrc / timesrc / vrt.asm < prev    next >
Encoding:
Assembly Source File  |  1994-02-23  |  5.7 KB  |  232 lines

  1.         .386p
  2. code32  segment para public use32
  3.         assume cs:code32, ds:code32
  4.  
  5. include pmode.inc
  6.  
  7. public  _vrt_rout, _vrt_timer, _vrt_palptr, _vrt_pallen, _vrt_palindex
  8.  
  9. public  _vrt_init, _vrt_uninit, _vrt_settimer
  10.  
  11. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  12. ; DATA
  13. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  14. align 4
  15. ormirq0vect     dd      ?
  16. opmirq0vect     dd      ?
  17.  
  18. _vrt_rout       dd      _ret            ; routine to call on every retrace
  19. _vrt_timer      dd      0               ; incrementing timer per retrace
  20. _vrt_palptr     dd      ?               ; ptr to RGB data for pal setting
  21. _vrt_pallen     dw      ?               ; number of colors to set left
  22. _vrt_palindex   db      ?               ; next color to set
  23.  
  24. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  25. ; CODE
  26. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  27.  
  28. ;═════════════════════════════════════════════════════════════════════════════
  29. align 4
  30. vrtirqpm:
  31.         push eax edx
  32.         mov dx,3dah
  33.         in al,dx
  34.         push ds
  35.         mov ds,cs:_seldata
  36.         and eax,8
  37.         dec eax
  38.         neg eax
  39.         add vrtv,ax
  40.         in al,dx
  41.         test al,8
  42.         jz $-3
  43.         mov ax,vrtv
  44.         out 40h,al
  45.         mov al,ah
  46.         out 40h,al
  47.         mov al,20h
  48.         out 20h,al
  49.         sti
  50.         cld
  51.         push ecx esi
  52.         movzx ecx,_vrt_pallen
  53.         or ecx,ecx
  54.         jz short vrtirqpmf0
  55.         mov dx,3c8h
  56.         mov al,_vrt_palindex
  57.         out dx,al
  58.         inc edx
  59.         mov esi,ecx
  60.         cmp ecx,80h
  61.         jbe short vrtirqpmf1
  62.         mov ecx,80h
  63. vrtirqpmf1:
  64.         sub esi,ecx
  65.         add al,cl
  66.         mov _vrt_pallen,si
  67.         mov _vrt_palindex,al
  68.         mov esi,_vrt_palptr
  69.         lea ecx,[ecx*2+ecx]
  70.         rep outsb
  71.         mov _vrt_palptr,esi
  72. vrtirqpmf0:
  73.         inc _vrt_timer
  74.         call _vrt_rout
  75.         pop esi ecx ds edx eax
  76.         iretd
  77.  
  78. ;═════════════════════════════════════════════════════════════════════════════
  79. align 4
  80. vrtirqrm:                       ; This is 16bit code in a 32bit segment
  81.         db 50h,52h              ; PUSH AX DX
  82.         db 0bah,0dah,3          ; MOD DX,3dah
  83.         db 0ech                 ; IN AL,DX
  84.         db 25h,8,0              ; AND AX,8
  85.         db 48h                  ; DEC AX
  86.         db 0f7h,0d8h            ; NEG AX
  87.         db 2eh,1,6              ; ADD CS:VRTV,AX
  88. vrtirqrmm0      dw      ?       ;
  89.         db 0ech                 ; IN AL,DX
  90.         db 0a8h,8               ; TEST AL,8
  91.         db 74h,0fbh             ; JZ SHORT $-3
  92.         db 0ebh,0               ; JMP SHORT $+2
  93.         db 0b8h                 ; MOV AX,vrtv
  94. vrtv    dw      4100h           ;
  95.         db 0e6h,40h             ; OUT 40h,AL
  96.         db 88h,0e0h             ; MOV AL,AH
  97.         db 0e6h,40h             ; OUT 40h,AL
  98.         db 2eh,066h,0ffh,6      ; INC DWORD PTR CS:_VRT_TIMER
  99. vrtirqrmm1      dw      ?       ;
  100.         db 05ah                 ; POP DX
  101.         db 0b0h,20h             ; MOV AL,20h
  102.         db 0e6h,20h             ; OUT 20h,AL
  103.         db 58h                  ; POP AX
  104.         db 0cfh                 ; IRET
  105.  
  106. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  107. ; Set up vertical retrace stuff
  108. ; Out:
  109. ;   EAX,BX,EDX - ?
  110. ; Notes:
  111. ;   Uses IRQ 0.
  112. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  113. _vrt_init:
  114.         mov ax,900h
  115.         int 31h
  116.         push ax
  117.  
  118.         mov eax,offset _vrt_timer
  119.         add eax,_code32a
  120.         shl eax,12
  121.         shr ax,12
  122.         mov vrtirqrmm1,ax
  123.         mov edx,offset vrtv-offset _vrt_timer
  124.         add dx,ax
  125.         mov vrtirqrmm0,dx
  126.         mov edx,offset vrtirqrm-offset _vrt_timer
  127.         add ax,dx
  128.         xchg eax,gs:[8*4]
  129.         mov ormirq0vect,eax
  130.  
  131.         xor bl,bl
  132.     call _getirqvect
  133.     mov opmirq0vect,edx
  134.         mov edx,offset vrtirqpm
  135.         call _setirqvect
  136.  
  137.         mov al,30h
  138.         out 43h,al
  139.         mov al,00h
  140.         out 40h,al
  141.         mov al,41h
  142.         out 40h,al
  143.  
  144.         call _vrt_settimer
  145.  
  146.         pop ax
  147.         int 31h
  148.         ret
  149.  
  150. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  151. ; Uninit vertical retrace stuff
  152. ; Out:
  153. ;   AX,BX,EDX - ?
  154. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  155. _vrt_uninit:
  156.         mov ax,900h
  157.         int 31h
  158.         push ax
  159.  
  160.         mov edx,ormirq0vect
  161.         mov gs:[8*4],edx
  162.         mov edx,opmirq0vect
  163.         xor bl,bl
  164.         call _setirqvect
  165.  
  166.         mov al,36h
  167.         out 43h,al
  168.         xor al,al
  169.         out 40h,al
  170.         out 40h,al
  171.  
  172.         pop ax
  173.         int 31h
  174.         ret
  175.  
  176. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  177. ; Set timer to current retrace period exactly
  178. ; Out:
  179. ;   AX,BX,DX - ?
  180. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  181. _vrt_settimer:
  182.         mov ax,900h
  183.         int 31h
  184.         push ax
  185.  
  186.         mov al,30h
  187.         out 43h,al
  188.         mov dx,3dah
  189.         in al,dx
  190.         test al,8
  191.         jnz $-3
  192.         in al,dx
  193.         test al,8
  194.         jz $-3
  195.         xor al,al
  196.         out 40h,al
  197.         out 40h,al
  198.  
  199.         in al,dx
  200.         test al,8
  201.     jnz $-3
  202.         in al,dx
  203.         test al,8
  204.         jz $-3
  205.         in al,40h
  206.     mov ah,al
  207.     in al,40h
  208.     xchg al,ah
  209.     neg ax
  210.         sub ax,0c0h
  211.         mov vrtv,ax
  212.     mov bx,ax
  213.  
  214.         in al,dx
  215.         test al,8
  216.         jz $-3
  217.         in al,dx
  218.         test al,8
  219.         jnz $-3
  220.     mov al,bl
  221.         out 40h,al
  222.     mov al,bh
  223.         out 40h,al
  224.  
  225.         pop ax
  226.         int 31h
  227.         ret
  228.  
  229. code32  ends
  230.         end
  231.  
  232.